package com.five.admin.service.impl;

import com.five.admin.dao.ArticleListMapper;
import com.five.admin.service.ArticleListService;
import com.five.entity.CourseClassify;
import com.five.entity.qo.ArticleQo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author ：vizi
 * @date ：Created in 2021/6/17 17:52
 */
@Service
public class ArticleListServiceImpl implements ArticleListService {

    @Autowired
    private ArticleListMapper articleListMapper;

    /**
     * 显示文章列表
     * @return
     */
    @Override
    public List<ArticleQo> selectArticleList() {
        List<ArticleQo> List = articleListMapper.selectArticleList();
        return List;
    }

    /**
     * 根据Id查询文章信息
     * @param id
     * @return
     */
    @Override
    public ArticleQo findById(long id) {
        return articleListMapper.findById(id);
    }

    /**
     * 根据ID删除文章
     * @param id
     */
    @Override
    public void deleteArticle(long id) {
        articleListMapper.deleteArticle(id);
    }

    /**
     * 删除选中文章
     * @param ids
     */
    @Override
    public void deleteSelectArticle(long[] ids) {
        for (int i = 0; i <ids.length ; i++) {
            articleListMapper.deleteArticle(ids[i]);
        }

    }

    /**
     * 模糊查询
     * @param name
     * @param page
     * @return
     */
    @Override
    public List<ArticleQo> fuzzyQueryByTypename(String name, int page) {
        return articleListMapper.fuzzyQueryByTypename(name,(page-1)*10);
    }

    @Override
    public int countArticle(String name) {
        return articleListMapper.countArticle(name);
    }
}
